package org.csu.tank.bean;


import com.almasb.fxgl.core.math.FXGLMath;
import org.csu.tank.GameConfig;

public class SucceedIntegration {
    private boolean isDoubleMode;
    private Integer playerId;
    private Integer level1Tank;     // 玩家消灭的1级坦克数量
    private Integer level2Tank;
    private Integer level3Tank;
    private Integer level4Tank;
    private Integer starsNum;       // 玩家获得星的数量
    private String level;          // 当前游戏关卡

    private SucceedIntegration(Integer playerId,
                               Integer level1TankNum,
                               Integer level2TankNum,
                               Integer level3TankNum,
                               Integer level4TankNum,
                               Integer starsNum,
                               boolean isDoubleMode,
                               String level) {
        this.playerId = playerId;
        this.level1Tank = level1TankNum;
        this.level2Tank = level2TankNum;
        this.level3Tank = level3TankNum;
        this.level4Tank = level4TankNum;
        this.starsNum = starsNum;
        this.isDoubleMode = isDoubleMode;
        this.level = level;
    }

    // 非双人模式的初始化
    public static SucceedIntegration succeedNotInDoubleMode(Integer playerId,
                                                            Integer level1TankNum,
                                                            Integer level2TankNum,
                                                            Integer level3TankNum,
                                                            Integer level4TankNum,
                                                            Integer starsNum,
                                                            String level) {
        if (level1TankNum == 0 && level2TankNum == 0 && level3TankNum == 0) {   // 当前是多人PVP模式
            return new SucceedIntegration(playerId%10, 0, 0, 0, level4TankNum, 5, false, "PVP");
        } else if (level1TankNum == 0 && level2TankNum == 0 && level3TankNum == 1) {  // 当前模式是普通单人模式
            int r1 = FXGLMath.random(0, GameConfig.ENEMY_AMOUNT/5);
            int r2 = FXGLMath.random(0, GameConfig.ENEMY_AMOUNT/5);
            int r3 = FXGLMath.random(0, GameConfig.ENEMY_AMOUNT*3/10);
            return new SucceedIntegration(1, r1, r2, r3, GameConfig.ENEMY_AMOUNT - r1 - r2 - r3, 3, false, Integer.parseInt(level)+1+"");
        }
        return new SucceedIntegration(playerId, level1TankNum, level2TankNum, level3TankNum, level4TankNum, starsNum, false, "PVE");
    }

    public boolean isDoubleMode() {
        return isDoubleMode;
    }

    public void setDoubleMode(boolean doubleMode) {
        isDoubleMode = doubleMode;
    }

    public Integer getPlayerId() {
        return playerId;
    }

    public void setPlayerId(Integer playerId) {
        this.playerId = playerId;
    }

    public Integer getLevel1Tank() {
        return level1Tank;
    }

    public void setLevel1Tank(Integer level1Tank) {
        this.level1Tank = level1Tank;
    }

    public Integer getLevel2Tank() {
        return level2Tank;
    }

    public void setLevel2Tank(Integer level2Tank) {
        this.level2Tank = level2Tank;
    }

    public Integer getLevel3Tank() {
        return level3Tank;
    }

    public void setLevel3Tank(Integer level3Tank) {
        this.level3Tank = level3Tank;
    }

    public Integer getLevel4Tank() {
        return level4Tank;
    }

    public void setLevel4Tank(Integer level4Tank) {
        this.level4Tank = level4Tank;
    }

    public Integer getStarsNum() {
        return starsNum;
    }

    public void setStarsNum(Integer starsNum) {
        this.starsNum = starsNum;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }
}
